home *** CD-ROM | disk | FTP | other *** search
GW-BASIC | 1985-11-01 | 3.3 KB | 75 lines |
- 1 'This program will create a CATALOG of all the files on drive C.
- 2 'It will search through all the directory and produce a listing
- 3 'on the printer in both alphabetical order and in decending size.
- 4 'Files that are special (hidden, read only, system) are flagged with
- 5 'an "*". The first 8 characters of the path (directory) name are
- 6 'also printed out. This is another example of the FCBREAD.BSV program.
- 7 'Jim Holtman
- 8 '35 Dogwood Trail
- 9 'Randolph, NJ 07869
- 10 ' (201) 361-3395
- 100 CLEAR ,&HF000 'make room for FCBREAD.BSV
- 110 BLOAD.BASE=&HF000<UNK! {0009}>'base @ of subroutine
- 120 COL=4:ROWS=83
- 130 NFILES=0
- 140 TWIDTH=132/COL
- 150 WIDTH "lpt1:",255
- 160 DIM SINPUT$(COL*ROWS+COL)
- 170 LPRINT CHR$(27) "@";<UNK! {0009}><UNK! {0009}>'init the EPSON printer
- 180 Q$="'"
- 190 INPUT "Output sorted by size? - (y/n) ",RESP$
- 200 BLOAD "fcbread.bsv",BLOAD.BASE
- 210 OPEN "\catalog.ust" FOR OUTPUT AS #1
- 220 IMAX%=100:INEXT%=1
- 230 O%=PEEK(BLOAD.BASE)+PEEK(BLOAD.BASE+1)*256+29+BLOAD.BASE
- 240 DIM DIR$(IMAX%)
- 250 CLS:PRINT "ROOT"
- 260 CHDIR "\" 'start at the ROOT
- 270 CUR$=""<UNK! {0009}>'current directory
- 280 INIT%=BLOAD.BASE+2:GETNEXT%=BLOAD.BASE+5<UNK! {0009}>'entry points for routines
- 290 VOLPAT$="???????????"<UNK! {0009}>'match ANY file name (check for VOLUME first)
- 300 DISK%=3:CALL INIT%(DISK%,VOLPAT$)<UNK! {0009}>'set to use C drive
- 310 VOLNAME$=SPACE$(14):CALL GETNEXT%(VOLNAME$,STATUS%)
- 320 IF STATUS%<0 THEN GOTO 340
- 330 IF STATUS%=8 THEN I%=INSTR(VOLNAME$,"."):VOLNAME$=MID$(VOLNAME$,3,I%-3)+MID$(VOLNAME$,I%+1):GOTO 350 ELSE GOTO 310
- 340 VOLNAME$=MID$(VOLNAME$,3,INSTR(VOLNAME$,".")-3)
- 350 PAT$="???????????"<UNK! {0009}>'match any file name
- 360 DISK%=3:CALL INIT%(DISK%,PAT$)
- 370 FILENAME$=SPACE$(14):CALL GETNEXT%(FILENAME$,STATUS%)
- 380 REM if no file found, go down last directory
- 390 IF STATUS%<0 THEN IF INEXT%>1 THEN INEXT%=INEXT%-1:CUR$=DIR$(INEXT%):CHDIR CUR$:PRINT CUR$:GOTO 360 ELSE GOTO 550
- 400 DISK$=LEFT$(FILENAME$,2):FILENAME$=MID$(FILENAME$,3)
- 410 IF (STATUS% AND &H10)=0 THEN GOTO 480<UNK! {0009}>'check for directory entry
- 420 IF LEFT$(FILENAME$,1)="." THEN GOTO 370 'ignore "." entries
- 430 FILENAME$=LEFT$(FILENAME$,INSTR(FILENAME$,".")-1)
- 440 IF INEXT%>IMAX% THEN PRINT "Directory Stack Overflow":GOTO 370
- 450 DIR$(INEXT%)=CUR$+"\"+FILENAME$
- 460 INEXT%=INEXT%+1
- 470 GOTO 370
- 480 REM IF (STATUS% AND &HF) <> 0 THEN GOTO 260 'ignore if not NORMAL file
- 490 FSIZE#=((PEEK(O%+3)*256+PEEK(O%+2))*256+PEEK(O%+1))*256+PEEK(O%)<UNK! {0009}>'get size
- 500 PRINT#1,USING "\ \ \ \#######";FILENAME$;CUR$;FSIZE#;
- 510 IF (STATUS% AND &HF) <> 0 THEN PRINT#1,"*" ELSE PRINT#1,<UNK! {0009}>'check for special file type
- 520 NFILES=NFILES+1
- 530 GOTO 370
- 540 REM Use the SORT command to sort the file (invoked with SHELL)
- 550 CLOSE:PRINT "SORTING FILE NAMES":START=TIMER:SHELL("sort <\catalog.ust >\catalog.srt"):PRINT TIMER-START " seconds":GOSUB 600
- 560 CLOSE:IF RESP$<>"y" THEN SYSTEM
- 570 PRINT "Sorting by size";:START=TIMER:SHELL("sort /r/+23 <\catalog.ust >\catalog.srt"): PRINT TIMER-START " seconds":GOSUB 600
- 580 SYSTEM
- 590 REM Print out the sorted file
- 600 OPEN "\catalog.srt" FOR INPUT AS #1
- 610 I=0:PAGENO=0
- 620 WHILE (NOT EOF(1)) AND (I<COL*ROWS)
- 630 I=I+1
- 640 LINE INPUT#1,SINPUT$(I)
- 650 WEND
- 660 FOR J=I+1 TO I+COL:SINPUT$(J)="":NEXT 'make sure blank entries at end of table
- 670 J=(I-1)\COL+1
- 680 PAGENO=PAGENO+1:LPRINT CHR$(18)CHR$(27)"-1System Catalog:" NFILES "Files " DATE$ " " TIME$ " Page -" PAGENO CHR$(27) "-0":LPRINT CHR$(15) CHR$(27) "0"
- 690 FOR K=1 TO J
- 700 FOR C=0 TO COL-1:LPRINT TAB(C*TWIDTH+1);MID$(SINPUT$(K+C*J),1,TWIDTH);:NEXT
- 710 NEXT
- 720 IF NOT EOF(1) THEN I=0:LPRINT CHR$(12);:GOTO 620
- 730 LPRINT CHR$(12):RETURN
-